from app.common.log_utils import logger
from app.globals import env
from app.macro import TradeAPIType


def run_at_09_10():
    # 通达信工作日9:10进行登录
    for worker in env.workers.values():
        if worker.account.api_type == TradeAPIType.TDX:
            worker.initialize()


def apply_new_stocks():
    for worker in env.workers.values():
        worker.apply_new_stocks()


def reverse_repo():
    for worker in env.workers.values():
        try:
            worker.reverse_repo()
        except Exception as e:
            logger.exception(e)
